package com.sf.langchain4j;

import com.sf.assistant.MemoryAssistant;
import dev.langchain4j.community.model.dashscope.QwenChatModel;
import dev.langchain4j.community.model.dashscope.WanxImageModel;
import dev.langchain4j.data.image.Image;
import dev.langchain4j.model.ollama.OllamaChatModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.model.output.Response;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;


@SpringBootTest
public class LLM {



//    @Test
//    public void test() {
//        OpenAiChatModel model = OpenAiChatModel.builder()
//                .baseUrl("http://langchain4j.dev/demo/openai/v1")
//                .apiKey("demo")
//                .modelName("gpt-4o-mini")
//                .build();
//
//
//        String answer = model.chat("你是谁");
//        System.out.println(answer);
//    }


    @Autowired
    private OpenAiChatModel model;


    @Test
    public void test2() {
        String answer = model.chat("你是deepseek吗");
        System.out.println(answer);
    }



    @Autowired
    private OllamaChatModel model2;

    @Test
    public void test3() {
        String answer = model2.chat("你好");
        System.out.println(answer);
    }



    @Autowired
    private QwenChatModel qwenChatModel;
    @Test
    public void testDashScopeQwen() {
//向模型提问
        String answer = qwenChatModel.chat("你好");
//输出结果
        System.out.println(answer);
    }


    @Test
    public void testDashScopeWanx(){
        WanxImageModel wanxImageModel = WanxImageModel.builder()
                .modelName("wanx2.1-t2i-plus")
                .apiKey(System.getenv("DASH_SCOPE_API_KEY"))
                .build();
        Response<Image> generate = wanxImageModel.generate("奇幻森林精灵：在一片弥漫着轻柔薄雾的" +
                "古老森林深处，阳光透过茂密枝叶洒下金色光斑。一位身材娇小、长着透明薄翼的精灵少女站在一朵硕大的蘑菇上。她 " +
                "有着海藻般的绿色长发，发间点缀着蓝色的小花，皮肤泛着珍珠般的微光。身上穿着由翠绿树叶和白色藤蔓编织而成的 " +
                "连衣裙，手中捧着一颗散发着柔和光芒的水晶球，周围环绕着五彩斑斓的蝴蝶，脚下是铺满苔藓的地面，蘑菇和蕨类植 " +
                "物丛生，营造出神秘而梦幻的氛围。");
        System.out.println(generate.content().url());
    }




    @Autowired
    private MemoryAssistant memoryAssistant;

    @Test
    public void testDashScopeMemory() {
        String an = memoryAssistant.chat("我是缓缓");
        System.out.println(an);
        String an1 = memoryAssistant.chat("我18岁");
        System.out.println(an1);
        String an2 = memoryAssistant.chat("你知道我是谁吗");
        System.out.println(an2);
    }








}
